package cn.watson.affairs;

import org.apache.rocketmq.client.producer.LocalTransactionState;
import org.apache.rocketmq.client.producer.TransactionListener;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.common.message.MessageExt;
/**
 * @Description: 定义事务监听器
 * @Author: Zhangrui
 * @Version: 1.0
 * @Date:  2022/7/26 16:55
 */
public class MyTranListener implements TransactionListener {

    @Override
    public LocalTransactionState executeLocalTransaction(Message message, Object o) {
        System.out.println("事务执行完毕啦！并且保存了本地事务啦！！！");
        // 返回保存信息，这里是保存成功
        return LocalTransactionState.COMMIT_MESSAGE;
    }

    @Override
    public LocalTransactionState checkLocalTransaction(MessageExt messageExt) {
        System.out.println("这里是本地事务查询！提交成功啦！！！！！");
        return LocalTransactionState.COMMIT_MESSAGE;
    }
}
